package Servidor;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;

import util.SocketManager;

public class ClienteLoc {

	public static final int puerto = 4444;
	public static String ip = "";
	public static String comando = "";
	public static String respuesta = "";
	public static String usuario_id = "";

	public static void main(String[] args) {

		System.out.println("Introduce la Ip a la que te quieres conectar");
		BufferedReader buffer = new BufferedReader(new InputStreamReader(
				System.in));
		SocketManager socketManager = null;
		Socket socket = null;
		try {
			System.out.println("Bienvenido.....");
			socket = new Socket(ip, puerto);
			socketManager = new SocketManager(socket);
			socketManager.InicializaStreams();
		} catch (Exception e) {
			// IMPOSIBLE CONECTAR CON EL SERVIDOR
		}
		System.out.println("Conectado con el servidor");
		try {
			while (!comando.equals("SALIR")) {
				System.out.println("Introduce un comando ");
				comando = buffer.readLine();
				socketManager.Escribir(comando + "\r\n");
				respuesta = socketManager.Leer();
				System.out.println(respuesta);

			}

			socketManager.CerrarSocket();
			socketManager.CerrarStreams();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
